﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.XCMG.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PMS.XCMG.Entity
{
    /// <summary>
    /// 缓存区管理
    /// </summary>
    public partial class StorageArea : BusEntity
    {
        /// <summary>
        /// 缓存区编码
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 缓存区名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 可缓存的物料编码
        /// </summary>
        public string MaterielId { set; get; }
    }

    public partial class StorageArea : BusEntity
    {
        /// <summary>
        /// 物料类型实体
        /// </summary>
        public MaterielInfor Materiel { set; get; }

        /// <summary>
        /// 物料规格清单-当前物料有哪些可选规格
        /// </summary>
        public List<StorageLocation> Locations { set; get; }
    }

    /// <summary>
    /// 实体配置
    /// OnModelCreating
    /// </summary>
    public class TeamStorageAreaConfig : BusEntityTypeConfig<StorageArea>, IEntityTypeConfiguration<StorageArea>
    {
        public override void Configure(EntityTypeBuilder<StorageArea> builder)
        {
            base.Configure(builder);

            #region 主外键关系
            #endregion

            #region 字段属性:最大长度,是否必需,默认值
            builder.Property(p => p.Code).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.Name).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.MaterielId).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            #endregion

            #region 备注
            builder.HasComment("缓存区");
            builder.Property(p => p.Code).HasComment("缓存区编码");
            builder.Property(p => p.Name).HasComment("缓存区名称");
            builder.Property(p => p.MaterielId).HasComment("可缓存物料");
            #endregion

            #region 种子数据
            //builder.HasData(new StorageArea { Id = "PS1001", Code = "PS_FTZC", Name = "封头总成_配送区", MaterielId = "1001", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new StorageArea { Id = "PS1002", Code = "PS_QZDTT", Name = "前锥段筒体_配送区", MaterielId = "1002", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new StorageArea { Id = "PS1003", Code = "PS_YZDTT", Name = "圆柱段筒体_配送区", MaterielId = "1003", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new StorageArea { Id = "PS1004", Code = "PS_HZQDTT", Name = "后锥前段筒体_配送区", MaterielId = "1004", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new StorageArea { Id = "PS1005", Code = "PS_HZHDTT", Name = "后锥后段筒体_配送区", MaterielId = "1005", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new StorageArea { Id = "PS1006", Code = "PS_JLG", Name = "进料管_配送区", MaterielId = "1006", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new StorageArea { Id = "PS1007", Code = "PS_JLLB", Name = "进料喇叭_配送区", MaterielId = "1007", CreateUserId = "1", ModifyUserId = "1" });
            builder.HasData(new StorageArea { Id = "HC1008", Code = "HC_YP", Name = "叶片_缓存区", MaterielId = "1008", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new StorageArea { Id = "PS1008", Code = "PS_YP", Name = "叶片_配送区", MaterielId = "1008", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new StorageArea { Id = "PS1009", Code = "PS_HDQI", Name = "后挡圈Ⅰ_配送区", MaterielId = "1009", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new StorageArea { Id = "PS1010", Code = "PS_HDQII", Name = "后挡圈ⅠⅠ_配送区", MaterielId = "1010", CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new StorageArea { Id = "PS1011", Code = "PS_HDQII", Name = "滚道_配送区", MaterielId = "1011", CreateUserId = "1", ModifyUserId = "1" });
            #endregion
        }
    }
}
